var app = angular.module('HelpConnect', ['ui']);

app.controller('HelpConnect', function($scope){

  $scope.list = [];
  $scope.currentEntry;
  $scope.checklist = true;

  $scope.FLAG      = 0;
  $scope.DELETE    = 1;
  $scope.HELP      = 2;
  $scope.PASSWORD  = 3;

  $scope.ALL       =  '';
  $scope.REQUESTS  = 'R';
  $scope.DONATIONS = 'D';

  $scope.mode = $scope.FLAG;
  $scope.date = new Date();

  $scope.type = '';

  $scope.setChecklistVisible = function(setting){
    $scope.checklist = setting;
  };

  $scope.openModal = function(entry, mode){
    $scope.currentEntry = entry;
    $scope.mode = mode;
    $scope.curtain = true;
  };

  $scope.closeModal = function(){
    $scope.curtain = false;
  };

  $scope.isOld = function(time){
    var itemTime = new Date(time);
    var dayOfMonth = itemTime.getDate();
    itemTime.setDate(dayOfMonth + 2);

    return itemTime <= $scope.date;
  };

  $scope.setFilter = function(setting){
    $scope.type = setting;
  }

});